<?php

class testWakStorage extends UnitTestCase {

	function setUp() {
		$this->kit='webappkit/testkit';
		//$this->name='teststorage';
		$this->cfg=array(
			'storage'=>array(
				'search'=>'teststorage/{{id}}{.{ext}}'
				,'class'=>'MockItem')
			,'criteria'=>array());
	}

	function testFactory() {
		$tool=wakStorage::Factory($this->kit,$this->cfg);
		$this->assertNoErrors();
		$this->assertIsA($tool,'wakStorage');
		$this->assertEqual($tool->getCfg(),$this->cfg);
		$this->assertEqual($tool->getSearchPattern(),'teststorage/{{id}}{.{ext}}');
	}

	function testSearch() {
		$tool=wakStorage::Factory($this->kit,$this->cfg);
		$this->assertNull(@$tool->getItem('MISSING'));
		$obj=$tool->getItem('README');
		$this->assertNoErrors();
		$this->assertIsA($obj,'MockItem');
		$this->assertEqual($obj->content,'This is a test storage');
	}
}


class MockItem {
	function MockItem($content) {
		$this->content=$content;
	}
}

?>